<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" alt="" />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
      <!--滚动条-->
      <!--<div class="swiper-scrollbar"   slot="scrollbar"></div>-->
    </swiper>
  </div>
</template>

<script>
  export default {
    name:'HomeSwiper',
    props:{
      list:Array
    },
    //子组件当中的数据声明要用函数的方式，避免组件重复使用的过程中，数据冲突
    data () {
      return {
        swiperOption:{
          pagination:'.swiper-pagination',
          //支持轮播循环播放
          loop:true,
          autoplay:true,
          speed:3000
        }
      }
    },
    computed:{
      showSwiper(){
        return this.list.length;
      }
    }
  }
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background: #fff !important
  .wrapper
    overflow:hidden
    width: 100%
    height:0
    padding-bottom:31.25%
    background: #eee
    .swiper-img
      width:100%

</style>
